var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        });
Object.defineProperty(i, "__esModule", {value: !0}), (i.BevNodeParallel = void 0);
var r = e("BehaviorTree"),
    s = (function (e) {
        function t(t, o) {
            void 0 === o && (o = null);
            var n = e.call(this, t, o) || this;
            (n.mab_ChildNodeStatus = new Array(r.k_BLimited_MaxChildNodeCnt)),
                (n.me_FinishCondition = r.E_ParallelFinishCondition.k_PFC_OR);
            for (var i = 0; i < r.k_BLimited_MaxChildNodeCnt; ++i)
                n.mab_ChildNodeStatus[i] = r.BevRunningStatus.k_BRS_Executing;
            return n;
        }
        return (
            a(t, e),
            (t.prototype.SetFinishCondition = function (e) {
                return (this.me_FinishCondition = e), this;
            }),
            (t.prototype._DoEvaluate = function (e) {
                for (var t = 0; t < this.mul_ChildNodeCount; ++t) {
                    var o = this.mao_ChildNodeList[t];
                    if (0 === this.mab_ChildNodeStatus[t] && !o.Evaluate(e)) return !1;
                }
                return !0;
            }),
            (t.prototype._DoTransition = function (e) {
                for (var t = 0; t < r.k_BLimited_MaxChildNodeCnt; ++t)
                    this.mab_ChildNodeStatus[t] = r.BevRunningStatus.k_BRS_Executing;
                for (t = 0; t < this.mul_ChildNodeCount; ++t) this.mao_ChildNodeList[t].Transition(e);
            }),
            (t.prototype._DoTick = function (e, t) {
                for (var o = 0, n = 0; n < this.mul_ChildNodeCount; ++n) {
                    var i = this.mao_ChildNodeList[n];
                    if (this.me_FinishCondition === r.E_ParallelFinishCondition.k_PFC_OR) {
                        if (
                            (this.mab_ChildNodeStatus[n] === r.BevRunningStatus.k_BRS_Executing &&
                                (this.mab_ChildNodeStatus[n] = i.Tick(e, t)),
                            this.mab_ChildNodeStatus[n] !== r.BevRunningStatus.k_BRS_Executing)
                        ) {
                            for (var a = 0; a < r.k_BLimited_MaxChildNodeCnt; ++a)
                                this.mab_ChildNodeStatus[a] = r.BevRunningStatus.k_BRS_Executing;
                            return r.BevRunningStatus.k_BRS_Finish;
                        }
                    } else
                        this.me_FinishCondition === r.E_ParallelFinishCondition.k_PFC_AND &&
                            (this.mab_ChildNodeStatus[n] === r.BevRunningStatus.k_BRS_Executing &&
                                (this.mab_ChildNodeStatus[n] = i.Tick(e, t)),
                            this.mab_ChildNodeStatus[n] !== r.BevRunningStatus.k_BRS_Executing && o++);
                }
                if (o === this.mul_ChildNodeCount) {
                    for (n = 0; n < r.k_BLimited_MaxChildNodeCnt; ++n)
                        this.mab_ChildNodeStatus[n] = r.BevRunningStatus.k_BRS_Executing;
                    return r.BevRunningStatus.k_BRS_Finish;
                }
                return r.BevRunningStatus.k_BRS_Executing;
            }),
            t
        );
    })(e("BevNode").BevNode);
i.BevNodeParallel = s;
